//
//  Blog.m
//  School+
//
//  Created by Sean Sebastian on 16/5/5.
//  Copyright © 2016年 Sean Sebastian. All rights reserved.
//

#import "Blog.h"

#import "UIImageView+WebCache.h"
#import "UserAccount.h"


#define baseURL @"http://localhost/SchoolPlus/images/Blog/"

@implementation Blog


- (NSString *)description
{
    return [NSString stringWithFormat:@"%@-%@-%@-%d-%d-%@" , self.adminName , self.blogTime , self.content , self.locationX, self.locationY , self.locationDetail];
}

- (NSMutableArray *)picDicts
{
    if (_picDicts == nil) {
        NSMutableArray *dict = [[NSMutableArray alloc] init];
        NSArray *picNames =  [self.picURLs componentsSeparatedByString:@"***"];
        NSMutableArray *arr = [[NSMutableArray alloc] init];
        for (int i = 0 ; i < picNames.count ; i++) {
            if ([picNames[i] isEqualToString:@""]) {
                continue;
            }
            NSString *imagePath = [baseURL stringByAppendingString:picNames[i]];
            
            NSURL *url = [NSURL URLWithString:imagePath];
            UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
            [dict addObject: @{imagePath : image}];
            [arr addObject: imagePath];
            
        }
        _picURLArray = arr;
        _picDicts = dict;
        return _picDicts;
    }
    return _picDicts;
}
@end
